package cc.booku.owlbox;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListAdapter;
import android.widget.TextView;

import java.util.ArrayList;


public class FileName_A extends BaseAdapter implements ListAdapter {

    private ArrayList<FileName_C> fileName_cArrayList;
    private int id;
    private Context context;
    private LayoutInflater inflater;

    public FileName_A(int sub_item, Context context, ArrayList<FileName_C> fileName_cArrayList) {
        this.fileName_cArrayList = fileName_cArrayList;
        this.context = context;
        this.id = sub_item;
        inflater = LayoutInflater.from(context);

    }


    @Override
    public int getCount() {
        return fileName_cArrayList.size();
    }

    @Override
    public Object getItem(int i) {
        return fileName_cArrayList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @SuppressLint("WrongConstant")
    @Override

    public View getView(int i, View view, ViewGroup viewGroup) {

        //owlTitle,owlNorm,owlType,owlTime;
        TextView owlTitle = null;
        TextView owlNorm = null;
        TextView owlType = null;
        TextView owlTime = null;

        FileName_A.ViewHolder viewHolder;
        if (view == null) {
            view = inflater.inflate(id, null);
            owlTitle = (TextView) view.findViewById(R.id.owlTitle);
            owlNorm = (TextView) view.findViewById(R.id.owlNorm);
            owlType = (TextView) view.findViewById(R.id.owlType);
            owlTime = (TextView) view.findViewById(R.id.owlTime);


            view.setTag(new ViewHolder(owlTitle, owlNorm, owlType, owlTime));
        } else {
            FileName_A.ViewHolder viewHolder1 = (FileName_A.ViewHolder) view.getTag(); // 重新获取ViewHolder
            owlTitle = viewHolder1.owlTitle;
            owlNorm = viewHolder1.owlNorm;
            owlType = viewHolder1.owlType;
            owlTime = viewHolder1.owlTime;

        }
        FileName_C fileName_c = (FileName_C) fileName_cArrayList.get(i); // 获取当前项的实例

        owlTitle.setText(fileName_c.getOwlTitle().toString());//对象为空
        owlNorm.setText(fileName_c.getOwlNorm().toString());

        owlType.setText(fileName_c.getOwlType().toString());//对象为空
        owlTime.setText(fileName_c.getOwlTime().toString());


        return view;

    }
//vod_id,vod_name,vod_class,vod_blurb,vod_add_time,vod_en;

    private final class ViewHolder {
        TextView owlTitle = null;
        TextView owlNorm = null;
        TextView owlType = null;
        TextView owlTime = null;


        public ViewHolder(TextView owlTitle, TextView owlNorm, TextView owlType, TextView owlTime) {
            this.owlTitle = owlTitle;
            this.owlNorm = owlNorm;
            this.owlType = owlType;
            this.owlTime = owlTime;

        }

    }

}

